package com.bridgetree.jubaocrm.ui;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.TextPaint;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.bridgetree.jubaocrm.R;
import com.bridgetree.jubaocrm.model.CRMUserBaseInfo;
import com.bridgetree.jubaocrm.service.JsonObjectPostRequest;
import com.bridgetree.jubaocrm.service.Network;
import com.bridgetree.jubaocrm.ui.widget.PullToRefreshBase.OnRefreshListener;
import com.bridgetree.jubaocrm.ui.widget.PullToRefreshListView;
import com.bridgetree.jubaocrm.ui.widget.XListView.IXListViewListener;
import com.bridgetree.jubaocrm.util.Announcement;
import com.bridgetree.jubaocrm.util.BasicInfomationInterface;
import com.bridgetree.jubaocrm.util.Groups;
import com.bridgetree.jubaocrm.util.Logger;
import com.bridgetree.jubaocrm.util.LoginError;
import com.bridgetree.jubaocrm.util.LoginInterface;
import com.bridgetree.jubaocrm.util.Mmember;
import com.bridgetree.jubaocrm.util.Projects;
import com.bridgetree.jubaocrm.util.Transaction;

/**
 * 
 * 主页面 5个page
 * 
 * @author Administrator
 * 
 */
public class ViewPageActivity extends Activity {
	private Logger logger=new Logger(ViewPageActivity.class);
	
	private Context mContext;
	private SharedPreferences prefs;
	private final String tag = "ViewPageActivity";

	private ViewPager viewPager;// 页卡内容
	private com.bridgetree.jubaocrm.ui.widget.MyDrawView imageView;// 动画图片
	private TextView textView1, textView2, textView3, textView4, textView5;
	private List<View> views;// Tab页面列表
	private int offset = 0;// 动画图片偏移量
	private int currIndex = 0;// 当前页卡编号
	private View view1, view2, view3, view4, view5;// 各个页卡
	private List<Projects> my_projects;
	private LoginInterface mLoginInterface;

	private int scrollTopBottom = 0;// top,0;bottom,1
	private PullToRefreshListView firstcategory1 = null;
	private PullToRefreshListView firstcategory2 = null;
	private PullToRefreshListView firstcategoryXM = null;
	private PullToRefreshListView firstcategory4 = null;
	private PullToRefreshListView firstcategory5 = null;
	private ListView actualListView1 = null;
	private ListView actualListView2 = null;
	private ListView actualListView3 = null;
	private ListView actualListView4 = null;
	private ListView actualListView5 = null;
	
	private float len1 = 0f, len2 = 0f, len3 = 0f, len4 = 0f, len5 = 0f;

	public static float screenW = 0;

	private String userName;
	private String passWord;

	private ImageView main_setting;
	private ImageView main_add;

	private RelativeLayout main_setting_RelativeLayout;
	private TextView main_setting_persinal;
	private TextView main_setting_editpassword;
	private TextView main_setting_exit;
	private RelativeLayout main_add_RelativeLayout;
	private TextView main_add_tr;

	private List<Announcement> mMyAnnouncementList;
	private List<Transaction> mTransactionList;
	private List<Announcement> mAnnouncementList;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		mContext = this;
		Intent intent = getIntent();
		if (intent == null) {
			Log.e(tag, "intent is null");
			return;
		}

		prefs = PreferenceManager
				.getDefaultSharedPreferences(ViewPageActivity.this);

		if (intent.getExtras() != null) {
			mLoginInterface = (LoginInterface) intent.getExtras()
					.getSerializable("LoginInterface");
			my_projects = mLoginInterface.getMy_projects();
			Log.e(tag, " my_projects  =  " + my_projects);
		}

		userName = prefs.getString(Contents.KEY_PERSONAL_USERNAME, "");
		passWord = prefs.getString(Contents.KEY_PERSONAL_PASSWORD, "");
		boolean LoginState = prefs.getBoolean(
				Contents.KEY_PERSONAL_LOGIN_STATE, false);
		if (!LoginState) {
			startActivity(new Intent(mContext, LoginActivity.class));
			finish();
		} else {
			InitImageView();
			InitViewPager();
			initMenuView();
			getJSONByVolley(userName, passWord);
		}
	}

	/**
	 * 蓝框上两个按钮
	 */
	private void initMenuView() {
		// TODO Auto-generated method stub
		// add
		main_add = (ImageView) findViewById(R.id.main_add);
		main_add_RelativeLayout = (RelativeLayout) findViewById(R.id.main_add_RelativeLayout);
		main_add_RelativeLayout.setVisibility(View.GONE);
		main_add_tr = (TextView) findViewById(R.id.main_add_tr);
		main_add.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (main_add_RelativeLayout.getVisibility() == View.GONE) {
					main_add_RelativeLayout.setVisibility(View.VISIBLE);
					main_setting_RelativeLayout.setVisibility(View.GONE);
				} else {
					main_add_RelativeLayout.setVisibility(View.GONE);
				}
			}
		});
		main_add_RelativeLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_add_RelativeLayout.setVisibility(View.GONE);
			}
		});
		main_add_tr.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_add_RelativeLayout.setVisibility(View.GONE);
				Intent intent = new Intent(mContext,
						AddTransactionActivity.class);
				Bundle bundle = new Bundle();
				bundle.putSerializable("LoginInterface", mLoginInterface);
				intent.putExtras(bundle);
				startActivityForResult(intent, 10002);
			}
		});

		// setting
		main_setting = (ImageView) findViewById(R.id.main_setting);
		main_setting_RelativeLayout = (RelativeLayout) findViewById(R.id.main_setting_RelativeLayout);
		main_setting_RelativeLayout.setVisibility(View.GONE);
		main_setting_persinal = (TextView) findViewById(R.id.main_setting_persinal);
		main_setting_editpassword = (TextView) findViewById(R.id.main_setting_editpassword);
		main_setting_exit = (TextView) findViewById(R.id.main_setting_exit);
		main_setting.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (main_setting_RelativeLayout.getVisibility() == View.GONE) {
					main_setting_RelativeLayout.setVisibility(View.VISIBLE);
				} else {
					main_setting_RelativeLayout.setVisibility(View.GONE);
				}
			}
		});
		main_setting_RelativeLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_setting_RelativeLayout.setVisibility(View.GONE);
			}
		});
		main_setting_persinal.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_setting_RelativeLayout.setVisibility(View.GONE);
				Intent intent = new Intent(mContext,
						PersonDocumentActivity.class);
				Bundle bundle = new Bundle();
				bundle.putSerializable("LoginInterface", mLoginInterface);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});
		main_setting_editpassword.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_setting_RelativeLayout.setVisibility(View.GONE);
				Intent intent = new Intent(mContext, EditPasswordActivity.class);
				Bundle bundle = new Bundle();
				bundle.putSerializable("LoginInterface", mLoginInterface);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});
		main_setting_exit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				main_setting_RelativeLayout.setVisibility(View.GONE);
				prefs.edit()
						.putBoolean(Contents.KEY_PERSONAL_LOGIN_STATE, false)
						.commit();
				startActivity(new Intent(mContext, LoginActivity.class));
				finish();
			}
		});

		findViewById(R.id.main_search).setOnClickListener(
				new OnClickListener() {
					@Override
					public void onClick(View v) {
						Intent intent = new Intent();
						Bundle bundle = new Bundle();
						bundle.putSerializable("LoginInterface",
								(Serializable) mLoginInterface);
						intent.putExtras(bundle);
						intent.setClass(ViewPageActivity.this,
								SearchProjectActivity.class);
						startActivity(intent);
					}
				});

	}

	/**
	 * 初始化pager5个页面
	 */
	private void InitViewPager() {
		viewPager = (ViewPager) findViewById(R.id.viewpager);
		views = new ArrayList<View>();
		LayoutInflater inflater = getLayoutInflater();
		view1 = inflater.inflate(R.layout.viewpage_1, null);
		view2 = inflater.inflate(R.layout.viewpage_2, null);
		view3 = inflater.inflate(R.layout.viewpage_3, null);
		view4 = inflater.inflate(R.layout.viewpage_4, null);
		view5 = inflater.inflate(R.layout.viewpage_5, null);
		views.add(view1);
		views.add(view2);
		views.add(view3);
		views.add(view4);
		views.add(view5);
		viewPager.setAdapter(new MyViewPagerAdapter(views));
		viewPager.setCurrentItem(0);
		viewPager.setOnPageChangeListener(new MyOnPageChangeListener());

		initview1();
		initview2();
		initview3();
		initview4();
		initview5();

	}

	private int pageIndex = 1;
	private PageCompanyAnnouncementAdapter mRuAdapter1 = null;
	private int scrollTopBottomca = 0;
	private void initview1() {
		// TODO Auto-generated method stub
		firstcategory1 = (PullToRefreshListView) view1.findViewById(R.id.firstcategory1);
		firstcategory1.setOnRefreshListener(new OnRefreshListener() {
			@Override
			public void onRefresh() {
				// if(mAnnouncementListSize<10){
				// if (mLoginInterface != null) {
				// getCompanyGongGao(pageIndex);
				// }
				// }else{
				if (scrollTopBottomca == 1) {
					pageIndex++;
					if (mLoginInterface != null) {
						getCompanyGongGao(pageIndex);
					}
				} else if (scrollTopBottomca == 0) {
					pageIndex = 1;
					if (mLoginInterface != null) {
						getCompanyGongGao(1);
					}
				}
				// }
			}
		});

		firstcategory1.setOnScrollListener(new OnScrollListener() {
			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
					  companyGongGaoLastPos= firstcategory1.getRefreshableView().getLastVisiblePosition();
				}
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
				if (firstVisibleItem + visibleItemCount == totalItemCount) {
					scrollTopBottomca = 1;
				} else if (firstVisibleItem == 0) {
					scrollTopBottomca = 0;
				}
			}
		});
		actualListView1 = firstcategory1.getRefreshableView();
	}

	/**
	 * 获取公司公告的数据
	 * 
	 * @param pageIndex
	 */
	private void getCompanyGongGao(final int pageIndex) {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			// http://crmsoap.woniuwo.cn/info?t=company&p=1&gid=(null)
			// &user_id=3a2ca74f8b484303ade9b7e2655994d9
			// &token=e5c13d5937de4de49fd42735e342d99b
			// &validation=gAJ9cQAoVQZsb2NhbGVxAVUFemhfQ05xAl
			String URL = Network.API_DOMAIN + "/info?t=company&p=" + pageIndex
					+ "&gid=(null)&user_id=" + mLoginInterface.getUser_id()
					+ "&token=" + mLoginInterface.getToken() + "&validation="
					+ CRMUserBaseInfo.kValication;

			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							System.out.println("公司公告 response=" + response);
							try {
								if (!response.isNull("info")) {
									String data = response.getString("info");
									if (data.equals("[]")) {
										Toast.makeText(mContext, "已经到最后了~",
												Toast.LENGTH_SHORT).show();
									} else {
										org.json.JSONArray jsonArr;
										jsonArr = response.getJSONArray("info");
										if (mAnnouncementList == null
												|| pageIndex == 1) {
											mAnnouncementList = new ArrayList<Announcement>();
										}
										if (jsonArr.length() > 0) {
											for (int i = 0; i < jsonArr
													.length(); i++) {
												Announcement mAnnouncement = new Announcement();
												JSONObject jsonObj2 = jsonArr
														.getJSONObject(i);
												if (!jsonObj2.isNull("id")) {
													String id = jsonObj2
															.getString("id");
													mAnnouncement.setId(id);
												}
												if (!jsonObj2.isNull("title")) {
													String title = jsonObj2
															.getString("title");
													mAnnouncement
															.setTitle(title);
												}
												mAnnouncementList
														.add(mAnnouncement);
											}
										}
										// mAnnouncementListSize =
										// mAnnouncementList.size();
										mRuAdapter1 = new PageCompanyAnnouncementAdapter(
												mContext, mAnnouncementList);
										actualListView1.setAdapter(mRuAdapter1);
										if (pageIndex > 1) {
											logger.debug("companyGongGaoLastPos:"+companyGongGaoLastPos);
											actualListView1.setSelection(companyGongGaoLastPos);
										}
									}
									if (firstcategory1 != null) {
										firstcategory1.onRefreshComplete();
									}
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														String desc = jsonObj2
																.getString("desc");
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
										}
									}
								}
							} catch (NumberFormatException e) {
								e.printStackTrace();
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}

	private int pageIndexma = 1;
	PageMyAnnouncementAdapter mRuAdapter2;
	private int scrollTopBottomma = 0;
	/**
	 * 初始化我的公告列表
	 */
	private void initview2() {
		// TODO Auto-generated method stub
		firstcategory2 = (PullToRefreshListView) view2.findViewById(R.id.firstcategory2);
		firstcategory2.setOnRefreshListener(new OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (scrollTopBottomma == 1) {
					pageIndexma++;
					if (mLoginInterface != null) {
						getMyGongGao(pageIndexma);
					}
				} else if (scrollTopBottomma == 0) {
					pageIndexma = 1;
					if (mLoginInterface != null) {
						getMyGongGao(pageIndexma);
					}
				}
			}
		});

		firstcategory2.setOnScrollListener(new OnScrollListener() {
			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
					  myGongGaoLastPos= firstcategory2.getRefreshableView().getLastVisiblePosition();
				}
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
				if (firstVisibleItem + visibleItemCount == totalItemCount) {
					scrollTopBottomma = 1;
				} else if (firstVisibleItem == 0) {
					scrollTopBottomma = 0;
				}
			}
		});
		actualListView2 = firstcategory2.getRefreshableView();
	}

	/**
	 * 获取我的公告的数据
	 * 
	 * @param pageIndex
	 */
	private void getMyGongGao(final int pageIndex) {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			String URL = Network.API_DOMAIN + "/info?t=mine&p=" + pageIndex
					+ "&gid=(null)&user_id=" + mLoginInterface.getUser_id()
					+ "&token=" + mLoginInterface.getToken() + "&validation="
					+ CRMUserBaseInfo.kValication;

			final ProgressDialog progressDialog = ProgressDialog.show(this,
					"请稍等", "...Loading...");
			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							if (progressDialog != null
									&& progressDialog.isShowing()) {
								progressDialog.dismiss();
							}
							System.out.println("我的公告 response=" + response);
							try {
								if (!response.isNull("info")) {
									String data = response.getString("info");
									if (data.equals("[]")) {
										Toast.makeText(mContext, "已经到最后了~",
												Toast.LENGTH_SHORT).show();
									} else {
										org.json.JSONArray jsonArr;
										jsonArr = response.getJSONArray("info");
										if (mMyAnnouncementList == null
												|| pageIndex == 1) {
											mMyAnnouncementList = new ArrayList<Announcement>();
										}
										if (jsonArr.length() > 0) {
											for (int i = 0; i < jsonArr
													.length(); i++) {
												Announcement mAnnouncement = new Announcement();
												JSONObject jsonObj2 = jsonArr
														.getJSONObject(i);
												if (!jsonObj2.isNull("id")) {
													String id = jsonObj2
															.getString("id");
													mAnnouncement.setId(id);
												}
												if (!jsonObj2.isNull("title")) {
													String title = jsonObj2
															.getString("title");
													mAnnouncement
															.setTitle(title);
												}
												if (!jsonObj2.isNull("is_done")) {
													boolean is_done = Boolean.valueOf(jsonObj2
															.getString("is_done"));
													mAnnouncement
															.setIs_done(is_done);
												}
												mMyAnnouncementList
														.add(mAnnouncement);
											}
										}
										// mAnnouncementListSizema=mAnnouncementList.size();
										mRuAdapter2 = new PageMyAnnouncementAdapter(
												mContext, mMyAnnouncementList);
										actualListView2.setAdapter(mRuAdapter2);
										if (pageIndex > 1) {
											actualListView2.setSelection(myGongGaoLastPos);
										}
									}
									if (firstcategory2 != null) {
										firstcategory2.onRefreshComplete();
									}
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														String desc = jsonObj2
																.getString("desc");
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
										}
									}
								}
							} catch (NumberFormatException e) {
								e.printStackTrace();
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							if (progressDialog != null
									&& progressDialog.isShowing()) {
								progressDialog.dismiss();
							}
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}

	private int pageIndexpr = 1;
	PageProjectAdapter mRuAdapter3;

	int projectLastPos=0;
	int companyGongGaoLastPos=0;
	int myGongGaoLastPos=0;
	int groupLastPos=0;
	int transactionLastPos=0;
	private int scrollTopBottompr = 0;
	private void initview3() {
		// TODO Auto-generated method stub
		firstcategoryXM = (PullToRefreshListView) view3.findViewById(R.id.firstcategoryXM);
		firstcategoryXM.setOnRefreshListener(new OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (scrollTopBottompr == 1) {
					pageIndexpr++;
					if (mLoginInterface != null) {
						getProjects(pageIndexpr);
					}
				} else if (scrollTopBottompr == 0) {
					pageIndexpr = 1;
					if (mLoginInterface != null) {
						getProjects(pageIndexpr);
					}
				}
			}
		});

		firstcategoryXM.setOnScrollListener(new OnScrollListener() {
			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
					  projectLastPos= firstcategoryXM.getRefreshableView().getLastVisiblePosition();
				}
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
				if (firstVisibleItem + visibleItemCount == totalItemCount) {
					scrollTopBottompr = 1;
				} else if (firstVisibleItem == 0) {
					scrollTopBottompr = 0;
				}
				System.out.println("=========" + scrollTopBottompr);
			}
		});
		actualListView3 = firstcategoryXM.getRefreshableView();

		// List<HashMap<String, Object>> proInfoListData = new
		// ArrayList<HashMap<String,Object>>();
		// HashMap<String, Object> map =null;
		//
		// map =new HashMap<String, Object>();
		// map.put("tv", "2015年度窗体广告");
		// proInfoListData.add(map);
		if (my_projects != null) {
			mRuAdapter3 = new PageProjectAdapter(this, my_projects);
			actualListView3.setAdapter(mRuAdapter3);
		}
	}

	/**
	 * 获取项目数据
	 * 
	 * @param pageIndex
	 */
	private void getProjects(final int pageIndex) {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			// //http://crmsoap.woniuwo.cn/projects?user_id=&token=4ec6c09a7e274adfa571caba103e5fa0&validation=gAJ9cQAoVQZsb2NhbGVxAVUFemhfQ05xAl&page=1
			String URL = Network.API_DOMAIN + "/projects?user_id="
					+ mLoginInterface.getUser_id() + "&token="
					+ mLoginInterface.getToken() + "&validation="
					+ CRMUserBaseInfo.kValication + "&page=" + pageIndex;

			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							System.out.println("获取项目数据  response=" + response);
							try {
								String user_id = "";
								String token = "";
								Log.e("wop",
										" response = " + response.toString());
								if (!response.isNull("my_projects")) {
									String myString = response.get(
											"my_projects").toString();
									if (myString.equals("[]")) {
										Toast.makeText(mContext, "已经到最后了~",
												Toast.LENGTH_SHORT).show();
									} else {
										org.json.JSONArray jsonArr;
										if (my_projects == null
												|| pageIndex == 1) {
											my_projects = new ArrayList<Projects>();
										}
										jsonArr = response
												.getJSONArray("my_projects");
										if (jsonArr.length() > 0) {
											for (int i = 0; i < jsonArr
													.length(); i++) {
												Projects my_project = new Projects();
												JSONObject jsonObj2 = jsonArr
														.getJSONObject(i);
												if (!jsonObj2
														.isNull("is_approved")) {
													boolean is_approved = Boolean.valueOf(jsonObj2
															.getString("is_approved"));
													my_project
															.setIs_approved(is_approved);
												}
												if (!jsonObj2
														.isNull("client_id")) {
													String client_id = jsonObj2
															.getString("client_id");
													my_project
															.setClient_id(client_id);
												}
												if (!jsonObj2
														.isNull("project_name")) {
													String project_name = jsonObj2
															.getString("project_name");
													my_project
															.setProject_name(project_name);
												}
												if (!jsonObj2
														.isNull("project_id")) {
													String project_id = jsonObj2
															.getString("project_id");
													my_project
															.setProject_id(project_id);
												}
												if (!jsonObj2
														.isNull("project_status")) {
													String project_status = jsonObj2
															.getString("project_status");
													my_project
															.setProcess_status(project_status);
												}
												my_project
														.setUser_id(mLoginInterface
																.getUser_id());
												my_project
														.setToken(mLoginInterface
																.getToken());
												my_projects.add(my_project);
											}
										}
										mLoginInterface
												.setMy_projects(my_projects);
										if (!response.isNull("fullname")) {
											String fullname = response.get(
													"fullname").toString();
											mLoginInterface
													.setFullname(fullname);
										}
										if (!response.isNull("errors")) {
											String errors = response.get(
													"errors").toString();
											if (errors.equals("[]")) {
											} else {
												org.json.JSONArray jsonArrs;
												if (!response.isNull("errors")) {
													LoginError mLoginError = new LoginError();
													jsonArrs = response
															.getJSONArray("errors");
													if (jsonArrs.length() > 0) {
														for (int i = 0; i < jsonArrs
																.length(); i++) {
															JSONObject jsonObj2 = jsonArrs
																	.getJSONObject(i);
															if (!jsonObj2
																	.isNull("desc")) {
																// dismissProgressDialog(progressDialog);
																String desc = jsonObj2
																		.getString("desc");
																openDailog(
																		"登录失败提示",
																		desc);
																mLoginError
																		.setDesc(desc);
															}
															if (!jsonObj2
																	.isNull("value")) {
																String value = jsonObj2
																		.getString("value");
																mLoginError
																		.setValue(value);
															}
														}
													}
													mLoginInterface
															.setErrors(mLoginError);
												}
											}
										}
										my_projects = mLoginInterface
												.getMy_projects();
										mRuAdapter3 = new PageProjectAdapter(
												mContext, my_projects);
										mRuAdapter3.notifyDataSetChanged();
										actualListView3.setAdapter(mRuAdapter3);
										if (pageIndex > 1) {
											actualListView3.setSelection(projectLastPos);
										}
									}
									if (firstcategoryXM != null) {
										firstcategoryXM.onRefreshComplete();
									}
								}
							} catch (NumberFormatException e) {
								e.printStackTrace();
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}

	PageGroupAdapter mRuAdapter4;
	private void initview4() {
		// TODO Auto-generated method stub
		firstcategory4 = (PullToRefreshListView) view4.findViewById(R.id.firstcategory4);
		firstcategory4.setOnRefreshListener(new OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (mLoginInterface != null) {
					getProjectsGroup();
				}
			}
		});

		firstcategory4.setOnScrollListener(new OnScrollListener() {
			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
			}
		});
		actualListView4 = firstcategory4.getRefreshableView();
	}

	/**
	 * 获取小组数据
	 * 
	 * @param pageIndex
	 */
	private void getProjectsGroup() {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			// //http://crmsoap.woniuwo.cn/groups?user_id=cd34350bb2844077bfbd4abe5ec56f99&token=4ec6c09a7e274adfa571caba103e5fa0&validation=gAJ9cQAoVQZsb2NhbGVxAVUFemhfQ05xAl
			String URL = Network.API_DOMAIN + "/groups?user_id="
					+ mLoginInterface.getUser_id() + "&token="
					+ mLoginInterface.getToken() + "&validation="
					+ CRMUserBaseInfo.kValication;

			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							System.out.println("获取小组数据  response=" + response);
							try {
								if (!response.isNull("my_groups")) {
									String data = response
											.getString("my_groups");
									if (data.equals("[]")) {
										Toast.makeText(mContext, "已经到最后了~",
												Toast.LENGTH_SHORT).show();
									} else {
										org.json.JSONArray jsonArr;
										jsonArr = response
												.getJSONArray("my_groups");
										List<Groups> mGroupsList = new ArrayList<Groups>();
										if (jsonArr.length() > 0) {
											for (int i = 0; i < jsonArr
													.length(); i++) {
												Groups mGroups = new Groups();
												JSONObject jsonObj2 = jsonArr
														.getJSONObject(i);
												if (!jsonObj2
														.isNull("group_id")) {
													String group_id = jsonObj2
															.getString("group_id");
													mGroups.setGroup_id(group_id);
												}
												if (!jsonObj2
														.isNull("group_name")) {
													String group_name = jsonObj2
															.getString("group_name");
													mGroups.setGroup_name(group_name);
												}
												mGroupsList.add(mGroups);
											}
										}
										mRuAdapter4 = new PageGroupAdapter(
												mContext, mGroupsList);
										actualListView4.setAdapter(mRuAdapter4);
									}
									if (firstcategory4 != null) {
										firstcategory4.onRefreshComplete();
									}
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														String desc = jsonObj2
																.getString("desc");
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
										}
									}
								}
							} catch (NumberFormatException e) {
								e.printStackTrace();
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}

	PageTransactionAdapter mRuAdapter5;

	private void initview5() {
		// TODO Auto-generated method stub
		firstcategory5 = (PullToRefreshListView) view5.findViewById(R.id.firstcategory5);
		firstcategory5.setOnRefreshListener(new OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (mLoginInterface != null) {
					getTransaction();
				}
			}
		});

		firstcategory5.setOnScrollListener(new OnScrollListener() {
			@Override
			public void onScrollStateChanged(AbsListView view, int scrollState) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onScroll(AbsListView view, int firstVisibleItem,
					int visibleItemCount, int totalItemCount) {
				// TODO Auto-generated method stub
			}
		});
		actualListView5 = firstcategory5.getRefreshableView();
	}

	/**
	 * 获取事务的数据
	 * 
	 * @param pageIndex
	 */
	private void getTransaction() {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			String URL = Network.API_DOMAIN + "/reminders?user_id="
					+ mLoginInterface.getUser_id() + "&token="
					+ mLoginInterface.getToken() + "&validation="
					+ CRMUserBaseInfo.kValication;
			// /reminders?user_id=cd34350bb2844077bfbd4abe5ec56f99
			// &token=b0a4c4f0cdcc4f668d0baf913fa8e463
			// &validation=gAJ9cQAoVQZsb2NhbGVxAVUFemhfQ05xAl

			final ProgressDialog progressDialog = ProgressDialog.show(this,
					"请稍等", "...Loading...");
			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							System.out.println("事务 response=" + response);
							dismissProgressDialog(progressDialog);
							try {
								if (!response.isNull("my_reminders")) {
									org.json.JSONArray jsonArr;
									jsonArr = response
											.getJSONArray("my_reminders");
									mTransactionList = new ArrayList<Transaction>();
									if (jsonArr.length() > 0) {
										for (int i = 0; i < jsonArr.length(); i++) {
											Transaction mTransaction = new Transaction();
											JSONObject jsonObj2 = jsonArr
													.getJSONObject(i);
											if (!jsonObj2.isNull("content")) {
												String content = jsonObj2
														.getString("content");
												mTransaction
														.setContent(content);
											}
											if (!jsonObj2.isNull("reminder_id")) {
												String reminder_id = jsonObj2
														.getString("reminder_id");
												mTransaction
														.setReminder_id(reminder_id);
											}
											if (!jsonObj2
													.isNull("reminder_time")) {
												String reminder_time = jsonObj2
														.getString("reminder_time");
												mTransaction
														.setReminder_time(reminder_time);
											}
											mTransactionList.add(mTransaction);
										}
									}
									mRuAdapter5 = new PageTransactionAdapter(
											mContext, mTransactionList);
									actualListView5.setAdapter(mRuAdapter5);
									if (firstcategory5 != null) {
										firstcategory5.onRefreshComplete();
									}
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														String desc = jsonObj2
																.getString("desc");
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
										}
									}
								}
							} catch (NumberFormatException e) {
								e.printStackTrace();
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							dismissProgressDialog(progressDialog);
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}

	/**
	 * 初始化动画，这个就是页卡滑动时，下面的横线也滑动的效果，在这里需要计算一些数据
	 */
	private void InitImageView() {
		textView1 = (TextView) findViewById(R.id.text1);
		textView2 = (TextView) findViewById(R.id.text2);
		textView3 = (TextView) findViewById(R.id.text3);
		textView4 = (TextView) findViewById(R.id.text4);
		textView5 = (TextView) findViewById(R.id.text5);

		imageView = (com.bridgetree.jubaocrm.ui.widget.MyDrawView) findViewById(R.id.cursor);

		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		screenW = dm.widthPixels;// 获取分辨率宽度

		TextPaint paint1 = textView1.getPaint();
		len1 = paint1.measureText(textView1.getText().toString());
		Log.e("wop", " len1 = " + len1);

		TextPaint paint2 = textView2.getPaint();
		len2 = paint2.measureText(textView2.getText().toString());
		Log.e("wop", " len2 = " + len2);

		TextPaint paint3 = textView3.getPaint();
		len3 = paint3.measureText(textView3.getText().toString());
		Log.e("wop", " len3 = " + len3);

		TextPaint paint4 = textView4.getPaint();
		len4 = paint4.measureText(textView4.getText().toString());
		Log.e("wop", " len4 = " + len4);

		TextPaint paint5 = textView5.getPaint();
		len5 = paint5.measureText(textView5.getText().toString());
		Log.e("wop", " len5 = " + len5);

		// offset = screenW / 7;// 计算偏移量
		// offset = screenW / 7 ;// 计算偏移量
		offset = (int) (screenW - len1 - len2 - len3 - len4 - len5) / 10;
		imageView.setting(offset, 0, offset + (int) len1, 0);

		textView1.setOnClickListener(new MyOnClickListener(0));
		textView2.setOnClickListener(new MyOnClickListener(1));
		textView3.setOnClickListener(new MyOnClickListener(2));
		textView4.setOnClickListener(new MyOnClickListener(3));
		textView5.setOnClickListener(new MyOnClickListener(4));

		textView1.setTextColor(Color.BLUE);
	}

	private void openDailog(String title, final String content) {
		new AlertDialog.Builder(mContext).setTitle(title).setMessage(content)
				.setPositiveButton("确定", new DialogInterface.OnClickListener() {

					public void onClick(DialogInterface dialog, int which) {
						if (content != null && content.trim().equals("用户不存在")) {
							// finish();
						}
						if("登陆失效，需重新登陆".equals(content) || "join(f.username.errors)".equals(content)){
							LoginUtil.executeLoginFaild(mContext);
						}

					}
				}).show();
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == 10001) {
			if (resultCode == 10001) {
				getJSONByVolley(userName, passWord);
			}
		}
		if (requestCode == 10004) {
			if (resultCode == 0x0004) {
				if (mLoginInterface != null) {
					getMyGongGao(1);
				}
			}
		}

		if (requestCode == 10002) {
			if (resultCode == 0x0002) {
				if (mLoginInterface != null) {
					getTransaction();
				}
			}
		}
		if (requestCode == 10005) {
			if (resultCode == 0x0005) {
				if (mLoginInterface != null) {
					getTransaction();
				}
			}
		}
	}

	/**
	 * 登录
	 */
	private void getJSONByVolley(String username, String password) {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else if (username.equals("") || password.equals("")) {
			openDailog("输入提示", "账号或密码不能为空！");
		} else {
			HashMap<String, String> mMap = new HashMap<String, String>();
			mMap.put("username", username);
			mMap.put("password", password);
			mMap.put("validation", CRMUserBaseInfo.kValication);
			String URL = Network.API_DOMAIN + "/login";

			final ProgressDialog progressDialog = ProgressDialog.show(this,
					"请稍等", "...Loading...");
			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectPostRequest jsonObjectPostRequest = new JsonObjectPostRequest(
					URL, new Response.Listener<JSONObject>() {

						@Override
						public void onResponse(JSONObject response) {
							dismissProgressDialog(progressDialog);
							try {
								String user_id = "";
								String token = "";
								Log.e("wop",
										" 登录 response = " + response.toString());
								mLoginInterface = new LoginInterface();
								if (!response.isNull("user_id")) {
									user_id = response.get("user_id")
											.toString();
									mLoginInterface.setUser_id(user_id);
								}
								if (!response.isNull("token")) {
									token = response.get("token").toString();
									mLoginInterface.setToken(token);
								}
								if (!response.isNull("my_projects")) {
									org.json.JSONArray jsonArr;
									my_projects = new ArrayList<Projects>();
									jsonArr = response
											.getJSONArray("my_projects");
									if (jsonArr.length() > 0) {
										for (int i = 0; i < jsonArr.length(); i++) {
											Projects my_project = new Projects();
											JSONObject jsonObj2 = jsonArr
													.getJSONObject(i);
											if (!jsonObj2.isNull("is_approved")) {
												boolean is_approved = Boolean.valueOf(jsonObj2
														.getString("is_approved"));
												my_project
														.setIs_approved(is_approved);
											}
											if (!jsonObj2.isNull("client_id")) {
												String client_id = jsonObj2
														.getString("client_id");
												my_project
														.setClient_id(client_id);
											}
											if (!jsonObj2
													.isNull("project_name")) {
												String project_name = jsonObj2
														.getString("project_name");
												my_project
														.setProject_name(project_name);
											}
											if (!jsonObj2.isNull("project_id")) {
												String project_id = jsonObj2
														.getString("project_id");
												my_project
														.setProject_id(project_id);
											}
											if (!jsonObj2
													.isNull("project_status")) {
												String project_status = jsonObj2
														.getString("project_status");
												my_project
														.setProcess_status(project_status);
											}
											my_project.setUser_id(user_id);
											my_project.setToken(token);
											my_projects.add(my_project);
										}
									}
									mLoginInterface.setMy_projects(my_projects);
								}
								if (!response.isNull("fullname")) {
									String fullname = response.get("fullname")
											.toString();
									mLoginInterface.setFullname(fullname);
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
										prefs.edit()
												.putString(
														Contents.KEY_PERSONAL_USERNAME,
														userName).commit();
										prefs.edit()
												.putString(
														Contents.KEY_PERSONAL_PASSWORD,
														passWord).commit();
										prefs.edit()
												.putString(
														Contents.KEY_PERSONAL_LOGIN_USEID,
														mLoginInterface
																.getUser_id())
												.commit();
										prefs.edit()
												.putString(
														Contents.KEY_PERSONAL_LOGIN_TAKEN,
														mLoginInterface
																.getToken())
												.commit();
										prefs.edit()
												.putBoolean(
														Contents.KEY_PERSONAL_LOGIN_STATE,
														true).commit();
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														// dismissProgressDialog(progressDialog);
														String desc = jsonObj2
																.getString("desc");
														openDailog("登录失败提示",
																desc);
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
											mLoginInterface
													.setErrors(mLoginError);
										}
									}
								}
								my_projects = mLoginInterface.getMy_projects();
								mRuAdapter3 = new PageProjectAdapter(mContext,
										my_projects);
								mRuAdapter3.notifyDataSetChanged();
								actualListView3.setAdapter(mRuAdapter3);
								if (mLoginInterface != null) {
									getCompanyGongGao(1);
								}
								if (mLoginInterface != null) {
									getMyGongGao(1);
								}
								if (mLoginInterface != null) {
									getProjects(1);
								}
								if (mLoginInterface != null) {
									getProjectsGroup();
								}
								if (mLoginInterface != null) {
									getTransaction();
								}
							} catch (JSONException e) {
								e.printStackTrace();
							}
						}

					}, new Response.ErrorListener() {

						@Override
						public void onErrorResponse(VolleyError error) {
							dismissProgressDialog(progressDialog);
							Toast.makeText(mContext, "网络未连接！",
									Toast.LENGTH_LONG).show();
						}
					}, mMap);
			requestQueue.add(jsonObjectPostRequest);
		}

	}

	private void dismissProgressDialog(final ProgressDialog progressDialog) {
		if (progressDialog.isShowing() && progressDialog != null) {
			progressDialog.dismiss();
		}
	}

	/**
	 * 头标点击监听
	 */
	private class MyOnClickListener implements OnClickListener {
		private int index = 0;

		public MyOnClickListener(int i) {
			index = i;
		}

		public void onClick(View v) {
			viewPager.setCurrentItem(index);
		}

	}

	public class MyViewPagerAdapter extends PagerAdapter {
		private List<View> mListViews;

		public MyViewPagerAdapter(List<View> mListViews) {
			this.mListViews = mListViews;
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			container.removeView(mListViews.get(position));
		}

		@Override
		public Object instantiateItem(ViewGroup container, int position) {
			container.addView(mListViews.get(position), 0);
			return mListViews.get(position);
		}

		@Override
		public int getCount() {
			return mListViews.size();
		}

		@Override
		public boolean isViewFromObject(View arg0, Object arg1) {
			return arg0 == arg1;
		}
	}

	public class MyOnPageChangeListener implements OnPageChangeListener {
		int one = 0;
		int two = 0;

		public void onPageScrollStateChanged(int arg0) {

		}

		public void onPageScrolled(int arg0, float arg1, int arg2) {

		}

		public void onPageSelected(int arg0) {
			Animation animation = null;
			// Log.e("wop", "arg0 = " + arg0 + "    //currIndex = " +
			// currIndex);
			switch (arg0) {
			case 0:
				if (currIndex == 1) {
					animation = new TranslateAnimation(offset * 2 + (int) len1,
							0, 0, 0);
				} else if (currIndex == 2) {
					animation = new TranslateAnimation(offset * 5 + (int) len1
							+ (int) len2, 0, 0, 0);
				} else if (currIndex == 3) {
					animation = new TranslateAnimation(offset * 7 + (int) len1
							+ (int) len2 + (int) len3, 0, 0, 0);
				} else if (currIndex == 4) {
					animation = new TranslateAnimation(offset * 9 + (int) len1
							+ (int) len2 + (int) len3 + (int) len4, 0, 0, 0);
				}
				imageView.setting(offset, 0, offset + (int) len1, 0);
				textView1.setTextColor(Color.BLUE);
				textView2.setTextColor(Color.BLACK);
				textView3.setTextColor(Color.BLACK);
				textView4.setTextColor(Color.BLACK);
				textView5.setTextColor(Color.BLACK);
				break;
			case 1:
				if (currIndex == 0) {
					animation = new TranslateAnimation(
							-offset * 2 - (int) len1, 0, 0, 0);
				} else if (currIndex == 2) {
					animation = new TranslateAnimation(offset * 2 + (int) len2,
							0, 0, 0);
				} else if (currIndex == 3) {
					animation = new TranslateAnimation(offset * 4 + (int) len2
							+ (int) len3, 0, 0, 0);
				} else if (currIndex == 4) {
					animation = new TranslateAnimation(offset * 6 + (int) len2
							+ (int) len3 + (int) len4, 0, 0, 0);
				}
				imageView.setting(offset * 3 + (int) len1, 0, offset * 3
						+ (int) len1 + (int) len2, 0);//
				textView1.setTextColor(Color.BLACK);
				textView2.setTextColor(Color.BLUE);
				textView3.setTextColor(Color.BLACK);
				textView4.setTextColor(Color.BLACK);
				textView5.setTextColor(Color.BLACK);
				break;
			case 2:
				if (currIndex == 0) {
					animation = new TranslateAnimation(-offset * 5 - (int) len1
							- (int) len2, 0, 0, 0);
				} else if (currIndex == 1) {
					animation = new TranslateAnimation(
							-offset * 2 - (int) len2, 0, 0, 0);
				} else if (currIndex == 3) {
					animation = new TranslateAnimation(offset * 2 + (int) len3,
							0, 0, 0);
				} else if (currIndex == 4) {
					animation = new TranslateAnimation(offset * 4 + (int) len3
							+ (int) len4, 0, 0, 0);
				}
				imageView.setting(offset * 5 + (int) len1 + (int) len2, 0,
						offset * 5 + (int) len1 + (int) len2 + (int) len3, 0);//
				textView1.setTextColor(Color.BLACK);
				textView2.setTextColor(Color.BLACK);
				textView3.setTextColor(Color.BLUE);
				textView4.setTextColor(Color.BLACK);
				textView5.setTextColor(Color.BLACK);
				break;
			case 3:
				if (currIndex == 0) {
					animation = new TranslateAnimation(-offset * 7 - (int) len1
							- (int) len2 - (int) len3, 0, 0, 0);
				} else if (currIndex == 1) {
					animation = new TranslateAnimation(-offset * 4 - (int) len2
							- (int) len3, 0, 0, 0);
				} else if (currIndex == 2) {
					animation = new TranslateAnimation(
							-offset * 2 - (int) len3, 0, 0, 0);
				} else if (currIndex == 4) {
					animation = new TranslateAnimation(offset * 2 + (int) len4,
							0, 0, 0);
				}
				imageView.setting(offset * 7 + (int) len1 + (int) len2
						+ (int) len3, 0, offset * 7 + (int) len1 + (int) len2
						+ (int) len3 + (int) len4, 0);
				textView1.setTextColor(Color.BLACK);
				textView2.setTextColor(Color.BLACK);
				textView3.setTextColor(Color.BLACK);
				textView4.setTextColor(Color.BLUE);
				textView5.setTextColor(Color.BLACK);
				break;
			case 4:
				if (currIndex == 0) {
					animation = new TranslateAnimation(-offset * 9 - (int) len1
							- (int) len2 - (int) len3 - (int) len4, 0, 0, 0);
				} else if (currIndex == 1) {
					animation = new TranslateAnimation(-offset * 6 - (int) len2
							- (int) len3 - (int) len4, 0, 0, 0);
				} else if (currIndex == 2) {
					animation = new TranslateAnimation(-offset * 4 - (int) len3
							- (int) len4, 0, 0, 0);
				} else if (currIndex == 3) {
					animation = new TranslateAnimation(
							-offset * 2 - (int) len4, 0, 0, 0);
				}
				imageView.setting(offset * 9 + (int) len1 + (int) len2
						+ (int) len3 + (int) len4, 0, offset * 9 + (int) len1
						+ (int) len2 + (int) len3 + (int) len4 + (int) len5, 0);
				textView1.setTextColor(Color.BLACK);
				textView2.setTextColor(Color.BLACK);
				textView3.setTextColor(Color.BLACK);
				textView4.setTextColor(Color.BLACK);
				textView5.setTextColor(Color.BLUE);
				break;
			}

			currIndex = arg0;
			animation.setFillAfter(true);// True:图片停在动画结束位置
			animation.setDuration(300);

			AnimationSet set = new AnimationSet(true);
			set.addAnimation(animation);
			imageView.startAnimation(set);

			// Toast.makeText(ViewPageActivity.this,
			// "您选择了" + viewPager.getCurrentItem() + "页卡",
			// Toast.LENGTH_SHORT).show();
		}

	}

	// @Override
	// public boolean onKeyDown(int keyCode, KeyEvent event) {
	// // TODO Auto-generated method stub
	// switch (keyCode) {
	// case KeyEvent.KEYCODE_BACK:
	// main_setting_RelativeLayout.setVisibility(View.GONE);
	// prefs.edit().putBoolean(Contents.KEY_PERSONAL_LOGIN_STATE,
	// false).commit();
	// finish();
	// break;
	// }
	// return super.onKeyDown(keyCode, event);
	// }

	/**
	 * 获取基本信息
	 */
	private void getBasicInfomation(final Projects mProjects) {
		Network mNetword = new Network(mContext);
		if (!mNetword.isNetworkConnected()) {
			openDailog("网络提示", "网络未连接,请连接网络！");
		} else {
			String URL = Network.API_DOMAIN + "/project?project_id="
					+ mProjects.getProject_id() + "&user_id="
					+ mProjects.getUser_id() + "&token=" + mProjects.getToken()
					+ "&validation=" + CRMUserBaseInfo.kValication
					+ "&part=home";

			final ProgressDialog progressDialog = ProgressDialog.show(this,
					"网络数据", "...Loading...");
			RequestQueue requestQueue = Volley.newRequestQueue(mContext);
			JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
					Request.Method.GET, URL, null,
					new Response.Listener<JSONObject>() {
						@Override
						public void onResponse(JSONObject response) {
							try {
								// System.out.println("response="+response);
								if (progressDialog.isShowing()
										&& progressDialog != null) {
									progressDialog.dismiss();
								}
								BasicInfomationInterface mBasicInfomationInterface = new BasicInfomationInterface();
								if (!response.isNull("project")) {
									String project = response.get("project")
											.toString();
									Projects my_project = new Projects();
									JSONObject jsonObj2 = new JSONObject(
											project);
									if (!jsonObj2.isNull("trade")) {
										String trade = jsonObj2
												.getString("trade");
										my_project.setTrade(trade);
									}
									if (!jsonObj2.isNull("group_id")) {
										String group_id = jsonObj2
												.getString("group_id");
										my_project.setGroup_id(group_id);
									}
									if (!jsonObj2
											.isNull("created_user_fullname")) {
										String created_user_fullname = jsonObj2
												.getString("created_user_fullname");
										my_project
												.setCreated_user_fullname(created_user_fullname);
									}
									if (!jsonObj2.isNull("lock_end_date")) {
										String lock_end_date = jsonObj2
												.getString("lock_end_date");
										my_project
												.setLock_end_date(lock_end_date);
									}
									if (!jsonObj2.isNull("approved_by")) {
										String approved_by = jsonObj2
												.getString("approved_by");
										my_project.setApproved_by(approved_by);
									}
									if (!jsonObj2.isNull("created")) {
										String created = jsonObj2
												.getString("created");
										my_project.setCreated(created);
									}
									if (!jsonObj2.isNull("name")) {
										String name = jsonObj2
												.getString("name");
										my_project.setName(name);
									}
									if (!jsonObj2.isNull("import_level")) {
										String import_level = jsonObj2
												.getString("import_level");
										my_project
												.setImport_level(import_level);
									}
									if (!jsonObj2.isNull("project_id")) {
										String project_id = jsonObj2
												.getString("project_id");
										my_project.setProject_id(project_id);
									}
									if (!jsonObj2.isNull("process_status")) {
										String process_status = jsonObj2
												.getString("process_status");
										my_project
												.setProcess_status(process_status);

										mProjects
												.setProcess_status(process_status);
									}
									if (!jsonObj2.isNull("brand")) {
										String brand = jsonObj2
												.getString("brand");
										my_project.setBrand(brand);
									}
									if (!jsonObj2.isNull("approved_date")) {
										String approved_date = jsonObj2
												.getString("approved_date");
										my_project
												.setApproved_date(approved_date);
									}
									if (!jsonObj2.isNull("is_approved")) {
										boolean is_approved = Boolean.valueOf(jsonObj2
												.getString("is_approved"));
										my_project.setIs_approved(is_approved);
									}
									if (!jsonObj2.isNull("members")) {
										// String project_id =
										// jsonObj2.getString("members");
										org.json.JSONArray jsonArr;
										List<Mmember> members = new ArrayList<Mmember>();
										jsonArr = jsonObj2
												.getJSONArray("members");
										if (jsonArr.length() > 0) {
											for (int i = 0; i < jsonArr
													.length(); i++) {
												Mmember mmember = new Mmember();
												JSONObject jsonObj3 = jsonArr
														.getJSONObject(i);
												if (!jsonObj3.isNull("user_id")) {
													String user_id = jsonObj3
															.getString("user_id");
													mmember.setUser_id(user_id);
												}
												if (!jsonObj3
														.isNull("fullname")) {
													String fullname = jsonObj3
															.getString("fullname");
													mmember.setFullname(fullname);
												}
												members.add(mmember);
											}
										}
										my_project.setMembers(members);
									}
									mBasicInfomationInterface
											.setProject(my_project);
								}
								if (!response.isNull("is_user_approve")) {
									boolean is_user_approve = Boolean
											.valueOf(response.get(
													"is_user_approve")
													.toString());
									mBasicInfomationInterface
											.setIs_user_approve(is_user_approve);
								}
								if (!response.isNull("is_edit_project")) {
									boolean is_edit_project = Boolean
											.valueOf(response.get(
													"is_edit_project")
													.toString());
									mBasicInfomationInterface
											.setIs_edit_project(is_edit_project);
								}
								if (!response.isNull("errors")) {
									String errors = response.get("errors")
											.toString();
									if (errors.equals("[]")) {
									} else {
										org.json.JSONArray jsonArr;
										if (!response.isNull("errors")) {
											LoginError mLoginError = new LoginError();
											jsonArr = response
													.getJSONArray("errors");
											if (jsonArr.length() > 0) {
												for (int i = 0; i < jsonArr
														.length(); i++) {
													JSONObject jsonObj2 = jsonArr
															.getJSONObject(i);
													if (!jsonObj2
															.isNull("desc")) {
														String desc = jsonObj2
																.getString("desc");
														openDailog("失败提示", desc);
														mLoginError
																.setDesc(desc);
													}
													if (!jsonObj2
															.isNull("value")) {
														String value = jsonObj2
																.getString("value");
														mLoginError
																.setValue(value);
													}
												}
											}
											mBasicInfomationInterface
													.setErrors(mLoginError);
										}
									}
								}

							} catch (JSONException e) {
								e.printStackTrace();
							}
						}
					}, new Response.ErrorListener() {
						@Override
						public void onErrorResponse(VolleyError arg0) {
							System.out.println("sorry,Error");
						}
					});
			requestQueue.add(jsonObjectRequest);
		}
	}
}
